package com.weng.cloud.service8881.javax.validation.controller;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * @Author: weng
 * @Date: 2022/5/4
 * @Description: com.weng.cloud.service8881.javax.validation.controller
 *
 * spring controller中借助@NotNull注解可以抛出异常
 * 
 * 其他地方使用这类注解好像只是文档的作用...
 */
@RestController
@RequestMapping("/javax/validation/testValidation")
public class TestValidationController {

    @RequestMapping(value = "/testNotNull")
    public String testNotNull(@Valid User user){
        return "i wanna be a friend...";
    }

    public void testFinal(final String weng){
        //do not thing
    }

    public static void main(String[] args) {
        //编译是不会报错的-->final null
        new TestValidationController().testFinal(null);
    }
}

@Data
@AllArgsConstructor
class User{
    @NotNull(message = "哎哎哎")
    String name;
    //int age;
}

